// import store from '@/store'
import validate from "@/utils/validate";

export function menuPermissonsFilter(obj, menuPermissons=[]) {
    console.log(obj,'aa')
    // 对常见的“非”值，直接返回原来值
    if ([null, undefined, NaN, false].includes(obj)) return obj
    if (typeof obj !== 'object' && typeof obj !== 'function') {
        // 原始类型直接返回
        return obj
    }
    const o = validate.isArray(obj) ? [] : {}
    for (const i in obj) {
        if(obj.hasOwnProperty('name') && obj['meta']['permisson'] && !menuPermissons.includes(obj['meta']['permisson'])){
            o['hidden'] = true
        }
        if (obj.hasOwnProperty(i)) {
            o[i] = typeof obj[i] === 'object' ? menuPermissonsFilter(obj[i],menuPermissons) : obj[i]
        }
    }
    return o
}

